import { registerAs } from '@nestjs/config'
import * as path from 'path';

export default registerAs('database', () => ({
  type: 'mysql',
  host: process.env.DB_HOST,
  username: process.env.DB_USERNAME,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_DATABASE,
  port: parseInt(process.env.DB_PORT),
  logging: process.env.DB_LOGGING,
  logger: process.env.DB_LOGGER,
  entities: [path.join(__dirname, '../entity/**/*.entity{.ts,.js}')],
  migrationsRun: process.env.DB_MIGRATIONS_RUN === 'true',
  synchronize: process.env.DB_SYNCHRONIZE === 'true',
}));